from Monitor.NetworkMonitor import NetworkDelayMonitor,NetworkMonitor,MonitorType,NetworkBandWidthMonitor
from containernet.node import DockerSta
from OSM_Mininet_wifi.node import OSMDockerStaion,OSMDockerCloud
from containernet.cli import CLI
from containernet.term import makeTerm
from mininet.log import info, setLogLevel,output
from mn_wifi.mobility import Mobility
from mininet.node import Controller
from OSM_Mininet_wifi.net import OSM_Mininet_wifi
from mn_wifi.net import OVSKernelAP

setLogLevel('info')
net = OSM_Mininet_wifi(controller=Controller,autoAssociation=False)


net.addStation(**{'type': 'mp', 'name': 'mp0', 'location': ['28.191202963839157,112.97478083409786', '28.1974083349244,112.98089627065184'], 'position': '-255,-507,0', 'ip': '10.0.0.1/8', 'ip6': '2001:0:0:0:0:0:0:1/64', 'mac': '00:00:00:00:00:01', 'range': 500, 'speed': 50, 'dimage': 'ubuntu:test2', 'sysctls': {'net.ipv6.conf.all.disable_ipv6': '0'}},cls=OSMDockerStaion)
net.OSM_Mobility_For_ConfigurationData(**{'NodeMobilityConfig': {'speed': 50, 'coord': ['-257,-494,0', '-244,-499,0', '-244,-490,0', '-245,-489,0', '-243,-480,0', '-239,-446,0', '-231,-393,0', '-178,-404,0', '-94,-432,0', '-75,-385,0', '-72,-370,0', '-67,-350,0', '-56,-289,0', '-53,-273,0', '-57,-254,0', '-55,-234,0', '-39,-160,0', '-36,-149,0', '-24,-136,0', '26,-10,0', '34,31,0', '48,89,0', '66,166,0', '70,286,0', '151,282,0', '160,278,0', '176,275,0', '179,281,0', '188,286,0', '199,281,0', '235,279,0', '255,272,0', '257,271,0', '265,266,0', '282,256,0', '297,246,0', '310,234,0', '318,221,0', '337,181,0'], 'distance': 1330.2200652328147}, 'node': 'mp0'})
net.addDocker(**{'type': 'ec', 'name': 'ec0', 'location': [28.194179552391397, 112.97352790832521], 'position': [-378, -176, 0], 'ip': '10.0.0.4/8', 'ip6': '2001:0:0:0:0:0:0:4/64', 'mac': '00:00:00:00:00:04', 'range': 500, 'dimage': 'ubuntu:test2', 'sysctls': {'net.ipv6.conf.all.disable_ipv6': '0'}},cls=OSMDockerCloud)
net.addAccessPoint(**{'type': 'bs', 'name': 'bs2', 'location': [28.193839282063895, 112.97494411468507], 'position': [-239, -214, 0], 'ssid': 'ssid-bs2', 'ip': '10.0.0.5/8', 'ip6': '2001:0:0:0:0:0:0:5/64', 'mac': '00:00:00:00:00:05', 'range': 500, 'failMode': 'standalone'})
net.addAccessPoint(**{'type': 'bs', 'name': 'bs3', 'location': [28.19576243318881, 112.98250559606075], 'position': [502, 0, 0], 'ssid': 'ssid-bs3', 'ip': '10.0.0.6/8', 'ip6': '2001:0:0:0:0:0:0:6/64', 'mac': '00:00:00:00:00:06', 'range': 500, 'failMode': 'standalone'})
net.addDocker(**{'type': 'ec', 'name': 'ec1', 'location': [28.196651601642262, 112.98387888707637], 'position': [637, 99, 0], 'ip': '10.0.0.7/8', 'ip6': '2001:0:0:0:0:0:0:7/64', 'mac': '00:00:00:00:00:07', 'range': 500, 'dimage': 'ubuntu:test2', 'sysctls': {'net.ipv6.conf.all.disable_ipv6': '0'}},cls=OSMDockerCloud)
net.addDocker(**{'type': 'ec', 'name': 'ec2', 'location': [28.203751084273858, 112.97786235809328], 'position': [47, 888, 0], 'ip': '10.0.0.8/8', 'ip6': '2001:0:0:0:0:0:0:8/64', 'mac': '00:00:00:00:00:08', 'range': 500, 'dimage': 'ubuntu:test2', 'sysctls': {'net.ipv6.conf.all.disable_ipv6': '0'}},cls=OSMDockerCloud)
net.addAccessPoint(**{'type': 'ap', 'name': 'ap4', 'location': '28.202932325545056,112.97883633412837', 'position': '143,797,0', 'ssid': 'ssid-ap4', 'ip': '10.0.0.9/8', 'ip6': '2001:0:0:0:0:0:0:9/64', 'mac': '00:00:00:00:00:09', 'range': 50, 'failMode': 'standalone'})
net.startController(**{'controller': 'None', 'name': 'c', 'number': 1, 'ip': '127.0.0.1', 'port': 6653, 'protocol': 'tcp', 'app': 'simple_switch'})
net.configureWifiNodes()
net.addLink(**{'type': 'nl', 'node1': 'ec0', 'node2': 'bs2', 'delay': '0ms', 'bw': 10, 'jitter': '0ms', 'loss': 0})
net.addLink(**{'type': 'nl', 'node1': 'bs3', 'node2': 'ec1', 'delay': '0ms', 'bw': 10, 'jitter': '0ms', 'loss': 0})
net.addLink(**{'type': 'nl', 'node1': 'bs2', 'node2': 'ap4', 'delay': '0ms', 'bw': 10, 'jitter': '0ms', 'loss': 0})
net.addLink(**{'type': 'nl', 'node1': 'bs3', 'node2': 'ap4', 'delay': '0ms', 'bw': 10, 'jitter': '0ms', 'loss': 0})
net.addLink(**{'type': 'nl', 'node1': 'ap4', 'node2': 'ec2', 'delay': '0ms', 'bw': 10, 'jitter': '0ms', 'loss': 0})
net.OSM_Mobility_Setting(**{'mobility_start_time': 1, 'reverse': 0, 'ac_method': 'ssf', 'mob_rep': 1, 'mobility_mode': 'quickly'})
net.start()
thread_list = []
t=NetworkDelayMonitor('mp0', 'ec0', net, monitor_type= {'delay'}).start(data_storage_Directory='/home/kylin/Desktop/PythonProject/OSM_Mininet_WIFI/Mininet_WIFI/Network_Topology/Network_Topology_20240327153741139085.json',**{'period': 10}).thread_
thread_list.append(t)
for td in thread_list: td.join()
net.OSM_Experiment_Ended(data_storage_Directory='/home/kylin/Desktop/PythonProject/OSM_Mininet_WIFI/Mininet_WIFI/Network_Topology/Network_Topology_20240327153741139085.json')
net.stop()
